import os


def data_path() -> str:
    _path = r'data\data'
    data_dir = get_path(_path)
    # print(data_dir)
    return data_dir


def build_model_path(file_name: str) -> str:
    _path = r'model'
    _p = get_path(_path)
    if not os.path.exists(_p):
        os.makedirs(_p)
    _model_path = os.path.join(_p, os.path.normpath(file_name))
    # print(_model_path)
    return _model_path


def get_path(url: str) -> str:
    # 规范化url路径
    normalized_url = os.path.normpath(url)
    _root_path = root_path()
    _path = os.path.join(_root_path, normalized_url)
    return _path


def root_path():
    # 获取当前文件的绝对路径
    current_file_path = os.path.abspath(__file__)

    # 获取当前文件所在目录的绝对路径
    current_dir = os.path.dirname(current_file_path)

    # 获取项目的根目录
    project_root = os.path.dirname(current_dir)
    return project_root


if __name__ == '__main__':
    print(build_model_path('dqn.pth'))
